source('/home/jc148322/scripts/libraries/cool_functions.r')
library(SDMTools)

wd= '/home/jc148322/frog_declines/SDM/Pre_decline/' #your /models/ directory

var.dirs=list.files(wd)

out=NULL
for (v in var.dirs) {
	md=paste(wd,v,'/models/',sep='')
	species = list.files(md) #get a list of species

	AUCs=NULL
	#cycle through each of the species
	for (spp in species) { #spp=species[1]
		spp.dir = paste(md,spp,'/output/',sep=''); setwd(spp.dir) #set the working directory to the species directory
		auc=read.csv('maxentResults.csv',as.is=TRUE)
		auc=auc[1,6]
		AUCs=c(AUCs, auc)
	}
	out=rbind(out,c(v,AUCs))
}
colnames(out)=c('variables',species)

setwd(wd)
write.csv(out,'AUC_values.csv',row.names=FALSE)
